<@admin.header title="汽车类型列表">
<script type="text/javascript">
    $(document).ready(function(){
		App.ns('Category');
		
		Category.form = new App.common.Form({
			base:'${base}/car/category'
		});
		Category.search = function(){
			$('#searchForm').submit();
		}
		Category.delAll = function(){
			var ids = Category.form.getCheckboxValues();
			Category.form.deleteRecord(ids);
		}
		Category.del = function(ids){
			Category.form.deleteRecord(ids,null, function(){
				$("#tr_"+ids).hide();
				App.toast.success("操作成功");
			});
		}
		/**
		 * ajax 编辑类型
		 * @param {Object} id
		 * @param {Object} name
		 * @param {Object} sort
		 */
		Category.edit = function(id, name, sort){
			var c = {"id":id||0,"name":name||'',"sort":sort||0};
			//赋值到视图
			Category.form.render(c,"c_");
			App.Msg.show("tpl_category", "编辑汽车类型",function(){
				//从视图中得到对象数据
				var parms = Category.form.renderPost(c,"c_","category.");
				//验证数据
				if(isNaN(parms['category.sort'])){
					App.Msg.alert("排序必须为整数");
					return false;
				}
				
				//提交数据
				App.ajax.post("car/category/edit.do",parms,function(d){
					if(d.success)
						Category.search();
					else
						App.toast.error(d.message);
				});
			});
		}
    });
</script>
</@admin.header>
    <body>
        <div class="place">
            <span>位置：</span>
            <ul class="placeul">
                <li>
                    <a href="#">首页</a>
                </li>
                <li>
                    <a href="${base}/car/list.do">二手车管理</a>
                </li>
                <li>
                    <a href="">汽车类型列表</a>
                </li>
            </ul>
        </div>
        <div class="rightinfo">
        <!--默认查询表单-->
        <form action="list.do" method="get" id="searchForm">
            <input type="hidden" name="pageNo" value="1"/>
            <div class="tools">
                <ul class="toolbar">
                    <li class="click">
                        <a href="javascript:;" onclick="Category.edit();"><span><img src="${base}/resources/images/t01.png" /></span>添加</a>
                    </li>
                </ul>
            </div>
			</form>
            <table class="tablelist">
                <thead>
                    <tr>
                        <th width="30"><input name="" type="checkbox" onclick="Car.form.checkToggle('ids',this);"/></th>
						<th width="60">编号</th>
						<th>名称</th>
						<th width="100">排序</th>
                        <th width="205">操作</th>
                    </tr>
                </thead>
                <tbody>
                	<#if page??>
					<#list page.list as d>
                    <tr id="tr_${d.id}">
                        <td>
                            <input name="ids" type="checkbox" value="${d.id}" />
                        </td>
						<td>${d_index+1}</td>
                        <td>${d.name!''}</td>
						<td>${d.sort!'0'}</td>
                        <td style="padding:0px;">
                            <a href="javascript:Category.edit(${d.id},'${d.name!''}',${d.sort});" class="tablelink">编辑</a>
							&nbsp;
                        	<a href="javascript:Category.del('${d.id}')" class="tablelink">删除</a>
                        </td>
                    </tr>
					</#list>
					</#if>
                </tbody>
            </table>
			<@common.pagination />
        </div>
		
		<div class="formbody hide" id="tpl_category">
		    <div class="formtitle">
		        <span>编辑汽车类型</span>
		    </div>
			<input id="c_id" value="0" type="hidden"/>
		    <ul class="forminfo">
		        <li>
		            <label class="field">名称</label>
		            <input id="c_name" type="text" class="dfinput" /><i>&nbsp;</i>
		        </li>
				<li>
		            <label class="field">排序</label>
		            <input id="c_sort" type="text" class="dfinput"/><i>值越大越靠前</i>
		        </li>
		    </ul>
		</div>
    </body>
</html>